package com.zzy.chapter4.controller;

import com.zzy.chapter4.pojo.BusinessLaunch;
import com.zzy.chapter4.pojo.UserInfo;
import com.zzy.chapter4.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public String login(String account, String password) {
        return userService.login(account, password);
    }

    @PostMapping("register")
    public String register(@RequestBody UserInfo userInfo) {
        return userService.register(userInfo);
    }

    @PostMapping("/business/launch")
    public List<BusinessLaunch> launch(@RequestParam("city") String city, @RequestParam("sex") String sex, @RequestParam("product") String product) {
        return userService.filterBusinessLaunch(city, sex, product);
    }

    @PostMapping("/ticket")
    public Object ticket(String type, String productId, String content, String title, String taxId, String bankInfo) {
        return userService.createTicket(type, productId, content, title, taxId, bankInfo);
    }
}
